/*
 * @Author: Jimmy
 * @LastModifiedBy: Jimmy
 * @Date: 2024-04-03 21:09:22
 * @LastEditTime: 2025-02-25 21:08:01
 * @FilePath: /monitor_belt/src/App.tsx
 */
import { ConfigProvider } from 'antd'
import { BrowserRouter, useRoutes } from 'react-router-dom'
import { routers } from './routers';
import AuthRouter from './components/authRouter';
import { useEffect, useState } from 'react';
import { IRoute } from './routers/router.types';
import zhCN from 'antd/es/locale/zh_CN';
import { defaultThemeToken } from '@/styles/theme';
import '@/styles/index.scss'
import 'dayjs/locale/zh-cn';

function App() {
  const [routes, setRoutes] = useState<IRoute[]>([...routers]);
  
  useEffect(() => {
    setRoutes(routers);
  }, [])
  //项目路由处理集合
  const RouteElement = (props: { routes: Array<any> }) => {
    let element = useRoutes(props.routes);
    return element;
  }
  return (
    <>
      <ConfigProvider
        locale={zhCN}
        componentSize={'middle'}
        theme={{ ...defaultThemeToken }}>
        <BrowserRouter>
          <AuthRouter>
            <RouteElement routes={routes} />
          </AuthRouter>
        </BrowserRouter>
      </ConfigProvider>
    </>
  )
}

export default App
